import { loadPlugin, loadPluginFn } from '../../app/config/loadplugin.config.js';
import authService from '../../app/resolves/authService.js';
import getCourseList from '../../course/resolves/getCourseList.js';
import getGroupList from '../../runner/resolves/getGroupList.js';
import getRaceDetail from '../../../modules/race/resolves/getRaceDetail.js';
import getCpListCamera from '../../../modules/cp/resolves/getCpListCamera.js';

import smsHtml from 'ngtemplate!html!../../../tpls/service/service.sms.html';
import cfHtml from 'ngtemplate!html!../../../tpls/service/service.certificate.html';
import cfeditHtml from 'ngtemplate!html!../../../tpls/service/service.certificateEdit.html';
import rescueHtml from 'ngtemplate!html!../../../tpls/service/service.rescue.html';
import guntimeHtml from 'ngtemplate!html!../../../tpls/service/service.guntime.html';
import livevideoHtml from 'ngtemplate!html!../../../tpls/service/service.livevideo.html';
import servicepublishHtml from 'ngtemplate!html!../../../tpls/service/service.publish.html';


/**
 * ServiceRouter - config
 * 赛事模块路由设置
 */
ServiceRouter.$inject = ['$stateProvider', '$urlRouterProvider', '$httpProvider', '$locationProvider', '$ocLazyLoadProvider'];
function ServiceRouter($stateProvider, $urlRouterProvider, $httpProvider, $locationProvider, $ocLazyLoadProvider) {
	
	//set router
    $stateProvider
		
		// 成绩短信
		.state('dashboard.race.sms', {
		    url: '/service/sms',
		    data: { 
		        pageTitle: '短信服务' 
		    },
		    templateUrl: smsHtml,
		    controller: 'ServiceSmsController as vm',
		    resolve: {
		    	authService: authService,
		    	getCourseList: getCourseList,
		    	getGroupList: getGroupList,
		    	loadPlugin: loadPluginFn([loadPlugin.blink, loadPlugin.tabjs, loadPlugin.icheck, loadPlugin.dataTables])
		    }
		})

		// 证书下载
		.state('dashboard.race.certificate', {
		    url: '/service/certificate',
		    data: { 
		        pageTitle: '证书下载' 
		    },
		    templateUrl: cfHtml,
		    controller: 'ServiceCfController as vm',
		    resolve: {
		    	authService: authService,
		    	getCourseList: getCourseList
		    }
		})

		// 证书编辑
		.state('dashboard.race.certificateEdit', {
		    url: '/service/certificate/edit?course_id',
		    data: { 
		        pageTitle: '证书编辑' 
		    },
		    templateUrl: cfeditHtml,
		    controller: 'ServiceCfEditController as vm',
		    resolve: {
		    	authService: authService,
		    	loadPlugin: loadPluginFn([loadPlugin.jscolorui, loadPlugin.dropdown])
		    }
		})

		// 赛事救援
		.state('dashboard.race.rescue', {
		    url: '/service/rescue',
		    data: { 
		        pageTitle: '赛事救援' 
		    },
		    templateUrl: rescueHtml,
		    controller: 'ServiceRescueController as vm',
		    resolve: {
		    	authService: authService,
		    	getCourseList: getCourseList,
		    	getRaceDetail: getRaceDetail,
		    	loadPlugin: loadPluginFn([loadPlugin.tabjs])
		    }
		})

		// 修改发令时间
		.state('dashboard.race.guntime', {
		    url: '/service/guntime',
		    data: { 
		        pageTitle: '修改发令时间' 
		    },
		    templateUrl: guntimeHtml,
		    controller: 'ServiceGuntimeController as vm',
		    resolve: {
		    	authService: authService,
		    	getCourseList: getCourseList
		    }
		})

		// 视频直播
		.state('dashboard.race.livevideo', {
		    url: '/service/livevideo',
		    data: { 
		        pageTitle: '视频直播' 
		    },
		    templateUrl: livevideoHtml,
		    controller: 'ServiceLiveVideoController as vm',
		    resolve: {
		    	getCpListCamera: getCpListCamera,
		    	getCourseList: getCourseList,
		    	loadPlugin: loadPluginFn([loadPlugin.mediaelementandplayer])
		    }
		})

		// 服务发布
		.state('dashboard.race.servicepublish', {
		    url: '/service/publish',
		    data: { 
		        pageTitle: '服务发布' 
		    },
		    templateUrl: servicepublishHtml,
		    controller: 'ServicePublishController as vm',
		    resolve: {
		    	authService: authService,
		    	getRaceDetail: getRaceDetail,
		    	loadPlugin: loadPluginFn([loadPlugin.icheck])
		    }
		})
}

export default ServiceRouter;